/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kimstore.gui.main;

import com.kimstore.bean.Batch;
import com.kimstore.bean.Customer;
import com.kimstore.bean.Item;
import com.kimstore.bean.Order;
import com.kimstore.bean.Product;
import com.kimstore.bean.Staff;
import com.kimstore.bean.User;
import com.kimstore.dao.impl.GenericJpaDaoImpl;
import com.kimstore.factory.DaoFactory;
import com.kimstore.gui.base.BaseWindow;
import com.kimstore.gui.report.GenerateReportController;
import com.kimstore.main.controller.CustomerTabController;
import com.kimstore.main.controller.InventoryTabController;
import com.kimstore.main.controller.ItemsTabController;
import com.kimstore.main.controller.OrdersTabController;
import com.kimstore.main.controller.RepairTabController;
import com.kimstore.main.controller.StaffTabController;
import com.kimstore.main.controller.StocksArrivalTabController;
import com.kimstore.utilities.DateUtil;
import com.kimstore.utilities.PaginateSearchAndFilter;
import com.kimstore.utilities.Session;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class Inventory extends BaseWindow {

    private StocksArrivalTabController stocksArrivalTabController;
    private OrdersTabController ordersTabController;
    private InventoryTabController inventoryTabController;
    private StaffTabController staffTabController;
    private CustomerTabController customerTabController;
    private ItemsTabController itemsTabController;
    private RepairTabController repairTabController;
    private GenerateReportController reportController;

    /**
     * Creates new form Inventory
     */
    public Inventory() {
        initComponents();

        prepareTabs();
        restrictTabs(Session.getInstance().getUser());

        User user = Session.getInstance().getUser();
        
        if (user.getType() != User.TYPE_ADMIN) {
            jMenuItem2.setVisible(false);
            jMenu1.setVisible(false);
        }
        
        if(user.getLastLogin() != null) {
            usernameMenu.setText(user.getUsername() + " - " + DateUtil.formatDate(user.getLastLogin(), DateUtil.HUMAN_READABLE_FORMAT));
        } else {
            usernameMenu.setText(user.getUsername());
        }
        
    }

    private void restrictTabs(User user) {
        if (user.getType() != User.TYPE_ADMIN && user.getType() != User.TYPE_ADMIN_B) {
            stocksArrivalTable.getColumnModel().removeColumn(stocksArrivalTable.getColumnModel().getColumn(3));

            stocksArrivalTable.getColumnModel().getColumn(3).setMaxWidth(0);
            stocksArrivalTable.getColumnModel().getColumn(3).setMinWidth(0);
            stocksArrivalTable.getColumnModel().getColumn(3).setPreferredWidth(0);

            if (user.getType() == User.TYPE_STOCKS) {
                jTabbedPane1.setEnabledAt(3, false);
                jTabbedPane1.setEnabledAt(4, false);

                inventoryTabController.populateInventoryTable();
                ordersTabController.populateOrdersTable();
                ordersTabController.populateStaffComboBox();
            } else if (user.getType() == User.TYPE_SALES) {
                jTabbedPane1.setEnabledAt(2, false);
                jTabbedPane1.setEnabledAt(3, false);
                jTabbedPane1.setEnabledAt(4, false);
                newOrderButton.setEnabled(false);

                ordersTabController.populateOrdersTable();
                ordersTabController.populateStaffComboBox();
            } else if (user.getType() == User.TYPE_TECHNICAL) {
                jTabbedPane1.setEnabledAt(0, false);
                jTabbedPane1.setEnabledAt(1, false);
                jTabbedPane1.setEnabledAt(2, false);
                jTabbedPane1.setSelectedIndex(3);

                itemsTabController.populateItemsTable();
            }
            jTabbedPane1.setEnabledAt(5, false);
            jTabbedPane1.setEnabledAt(6, false);
        } else {
            if (user.getType() == User.TYPE_ADMIN_B ) {
                stocksArrivalTable.getColumnModel().removeColumn(stocksArrivalTable.getColumnModel().getColumn(3));

                stocksArrivalTable.getColumnModel().getColumn(3).setMaxWidth(0);
                stocksArrivalTable.getColumnModel().getColumn(3).setMinWidth(0);
                stocksArrivalTable.getColumnModel().getColumn(3).setPreferredWidth(0);
            }

            ordersTabController.populateOrdersTable();
            ordersTabController.populateStaffComboBox();
        }
    }

    private void prepareTabs() {
        ordersTabController = new OrdersTabController(this);
        ordersTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Order> psafOrder = new PaginateSearchAndFilter<Order>("Order", "order");

        psafOrder.addColumn(0, "id");
        psafOrder.addColumn(1, "staff.name");
        psafOrder.addColumn(2, "customerType");
        psafOrder.addColumn(3, "orderDate");
        psafOrder.addColumn(4, "status", false);
        psafOrder.setNextButton(ordersNextButton);
        psafOrder.setPrevButton(ordersPrevButton);
        psafOrder.setSearchField(ordersSearchField, "Search Order ID");
        psafOrder.setSearchColumn(0);
        psafOrder.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getOrderDao());
        psafOrder.setPagesLabel(ordersPageLabel);
        psafOrder.setResultsPerPageField(resultsPerPageField);
        psafOrder.addFilter(staffFilterComboBox, 1, "staffName");
        psafOrder.addFilter(ordersCustomerTypeComboBox, 2, "customerType");
        // ordersTabController.setSearchFieldPromptText("Search Order ID");
        ordersTabController.setPsaf(psafOrder);
        ordersTabController.setSearchButton(ordersSearchButton);
        ordersTabController.setNextButton(ordersNextButton);
        ordersTabController.setPrevButton(ordersPrevButton);
        ordersTabController.setTable(ordersTable);
        ordersTabController.setStaffComboBox(staffFilterComboBox);
        ordersTabController.prepareUserInterface();
        ordersTabController.bindElements();

        inventoryTabController = new InventoryTabController(this);
        productsTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Product> psafInventory = new PaginateSearchAndFilter<Product>("Product", "product");

        psafInventory.addColumn(0, "name");
        psafInventory.addColumn(1, "specifications");
        psafInventory.addColumn(2, "availableStocks");
        psafInventory.addColumn(3, "basePrice");
        psafInventory.addColumn(4, "status");
        psafInventory.setNextButton(inventoryNextButton);
        psafInventory.setPrevButton(inventoryPreviousButton);
        psafInventory.setSearchField(inventorySearchField, "Search Product Names");
        psafInventory.setSearchColumn(0);
        psafInventory.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getProductDao());
        psafInventory.setPagesLabel(inventoryPageLabel);
        psafInventory.setResultsPerPageField(inventoryResultsPerPageField);
        psafInventory.addFilter(inventoryFilterComboBox, 3, "status");
        inventoryTabController.setPsaf(psafInventory);
        inventoryTabController.setSearchButton(inventorySearchButton);
        inventoryTabController.setPrevButton(inventoryPreviousButton);
        inventoryTabController.setNextButton(inventoryNextButton);
        inventoryTabController.setSearchFieldPromptText("Search Products");
        inventoryTabController.setTable(productsTable);
        inventoryTabController.setSearchField(inventorySearchField, 0);
        //inventoryTabController.addFilter(inventoryFilterComboBox, 3);
        inventoryTabController.prepareUserInterface();
        inventoryTabController.bindElements();

        stocksArrivalTabController = new StocksArrivalTabController(this);
        stocksArrivalTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Batch> psafStocksArrival = new PaginateSearchAndFilter<>("Batch", "batch");

        psafStocksArrival.addColumn(0, "number");
        psafStocksArrival.addColumn(1, "dateReceived");
        psafStocksArrival.addColumn(2, "receivedBy");
        psafStocksArrival.addColumn(3, "items", false);
        psafStocksArrival.addColumn(4, "purchaseCost");
        psafStocksArrival.setNextButton(stocksArrivalNextButton);
        psafStocksArrival.setPrevButton(stocksArrivalPrevButton);
        psafStocksArrival.setSearchField(stocksArrivalSearchField, "Search Batch Numbers");
        psafStocksArrival.setSearchColumn(0);
        psafStocksArrival.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getBatchDao());
        psafStocksArrival.setPagesLabel(stocksArrivalPageLabel);
        psafStocksArrival.setResultsPerPageField(stocksArrivalResultsPerPageField);
        //stocksArrivalTabController.setSearchFieldPromptText("Search Batch Number");
        stocksArrivalTabController.setPsaf(psafStocksArrival);
        stocksArrivalTabController.setSearchButton(stocksArrivalSearchButton);
        stocksArrivalTabController.setPrevButton(stocksArrivalPrevButton);
        stocksArrivalTabController.setNextButton(stocksArrivalNextButton);
        stocksArrivalTabController.setTable(stocksArrivalTable);
        //stocksArrivalTabController.setSearchField(stocksArrivalSearchField, 0);
        stocksArrivalTabController.prepareUserInterface();
        stocksArrivalTabController.bindElements();
        //stocksArrivalTabController.populateStocksArrivalTable();

        staffTabController = new StaffTabController(this);
        staffsTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Staff> psafStaff = new PaginateSearchAndFilter<Staff>("Staff", "staff");

        psafStaff.addColumn(0, "id");
        psafStaff.addColumn(1, "name");
        psafStaff.addColumn(2, null, false);
        psafStaff.setNextButton(staffNextButton);
        psafStaff.setPrevButton(staffPrevButton);
        psafStaff.setSearchField(staffSearchField, "Search Staffs");
        psafStaff.setSearchColumn(1);
        psafStaff.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getStaffDao());
        psafStaff.setPagesLabel(staffPageLabel);
        psafStaff.setResultsPerPageField(staffResultsPerPageField);
        staffTabController.setPsaf(psafStaff);
        staffTabController.setSearchButton(staffSearchButton);
        staffTabController.setPrevButton(staffPrevButton);
        staffTabController.setNextButton(staffNextButton);
        staffTabController.setTable(staffsTable);
        staffTabController.prepareUserInterface();
        staffTabController.bindElements();

        customerTabController = new CustomerTabController(this);
        customerTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Customer> psafCustomer = new PaginateSearchAndFilter<Customer>("Customer", "customer");

        psafCustomer.addColumn(0, "id");
        psafCustomer.addColumn(1, "name");
        psafCustomer.addColumn(2, null, false);
        psafCustomer.setNextButton(customersNextButton);
        psafCustomer.setPrevButton(customersPrevButton);
        psafCustomer.setSearchField(customerSearchField, "Search Customers");
        psafCustomer.setSearchColumn(1);
        psafCustomer.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getCustomerDao());
        psafCustomer.setPagesLabel(customersPageLabel);
        psafCustomer.setResultsPerPageField(customersResultsPerPageField);
        customerTabController.setPsaf(psafCustomer);
        customerTabController.setSearchButton(customersSearchButton);
        customerTabController.setPrevButton(customersPrevButton);
        customerTabController.setNextButton(customersNextButton);
        customerTabController.setTable(customerTable);
        customerTabController.prepareUserInterface();
        customerTabController.bindElements();

        itemsTabController = new ItemsTabController(this);
        itemsTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Item> psafItem = new PaginateSearchAndFilter<Item>("Item", "item");

        psafItem.addColumn(0, "serial");
        psafItem.addColumn(1, "product.name");
        psafItem.addColumn(2, "latestStatus");
        psafItem.setNextButton(itemsNextButton);
        psafItem.setPrevButton(itemsPrevButton);
        psafItem.addFilter(itemsComboBox, 2, "latestStatus");
        psafItem.setSearchField(itemsSearchField, "Search SKUs");
        psafItem.setSearchColumn(0);
        psafItem.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getItemDao());
        psafItem.setPagesLabel(itemsPageLabel);
        psafItem.setResultsPerPageField(itemsResultsPerPageField);
        itemsTabController.setPsaf(psafItem);
        itemsTabController.setSearchButton(itemsSearchButton);
        itemsTabController.setNextButton(itemsNextButton);
        itemsTabController.setPrevButton(itemsPrevButton);
        itemsTabController.setTable(itemsTable);
        itemsTabController.prepareUserInterface();
        itemsTabController.bindElements();

        repairTabController = new RepairTabController(this);
        repairTable.getTableHeader().setReorderingAllowed(false);
        PaginateSearchAndFilter<Item> psafRepair = new PaginateSearchAndFilter<>("Item", "item");

        psafRepair.getQueryElements().getStrictAttributes().add("item.repairDetail is not null");
        psafRepair.addColumn(0, "serial");
        psafRepair.addColumn(1, "product.name");
        psafRepair.addColumn(2, "repairDetail.receiveDate");
        psafRepair.addColumn(3, "repairDetail.releaseDate");
        psafRepair.addColumn(4, "repairDetail.currentStatus");
        psafRepair.addColumn(5, "latestStatus");
        psafRepair.addFilter(repairComboBox, 4, "currentStatus");
        psafRepair.setNextButton(repairNextButton);
        psafRepair.setPrevButton(repairPrevButton);
        psafRepair.setSearchField(repairSearchField, "Search SKUs");
        psafRepair.setSearchColumn(0);
        psafRepair.setDao((GenericJpaDaoImpl) DaoFactory.getInstance().getItemDao());
        psafRepair.setPagesLabel(repairPageLabel);
        psafRepair.setResultsPerPageField(repairResultsPerPageField);
        repairTabController.setPsaf(psafRepair);
        repairTabController.setSearchButton(repairSearchButton);
        repairTabController.setPrevButton(repairPrevButton);
        repairTabController.setNextButton(repairNextButton);
        repairTabController.setTable(repairTable);
        repairTabController.prepareUserInterface();
        repairTabController.bindElements();

        reportController = new GenerateReportController();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jProgressBar1 = new javax.swing.JProgressBar();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ordersTable = new org.jdesktop.swingx.JXTable();
        newOrderButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        staffFilterComboBox = new javax.swing.JComboBox();
        ordersPrevButton = new javax.swing.JButton();
        ordersPageLabel = new javax.swing.JLabel();
        ordersNextButton = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        ordersCustomerTypeComboBox = new javax.swing.JComboBox();
        ordersSearchButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        resultsPerPageField = new javax.swing.JFormattedTextField();
        ordersSearchField = new org.jdesktop.swingx.JXSearchField();
        jPanel4 = new javax.swing.JPanel();
        inventorySearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane2 = new javax.swing.JScrollPane();
        productsTable = new org.jdesktop.swingx.JXTable();
        newProductButton = new org.jdesktop.swingx.JXButton();
        jLabel4 = new javax.swing.JLabel();
        inventoryFilterComboBox = new javax.swing.JComboBox();
        inventorySearchButton = new javax.swing.JButton();
        inventoryNextButton = new javax.swing.JButton();
        inventoryPreviousButton = new javax.swing.JButton();
        inventoryPageLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        inventoryResultsPerPageField = new javax.swing.JFormattedTextField();
        jPanel5 = new javax.swing.JPanel();
        stocksArrivalSearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane3 = new javax.swing.JScrollPane();
        stocksArrivalTable = new org.jdesktop.swingx.JXTable();
        newStocksButton = new javax.swing.JButton();
        stocksArrivalSearchButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        stocksArrivalResultsPerPageField = new javax.swing.JFormattedTextField();
        stocksArrivalPageLabel = new javax.swing.JLabel();
        stocksArrivalPrevButton = new javax.swing.JButton();
        stocksArrivalNextButton = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        itemsSearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane6 = new javax.swing.JScrollPane();
        itemsTable = new org.jdesktop.swingx.JXTable();
        itemsComboBox = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        itemsPageLabel = new javax.swing.JLabel();
        itemsPrevButton = new javax.swing.JButton();
        itemsNextButton = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        itemsResultsPerPageField = new javax.swing.JFormattedTextField();
        itemsSearchButton = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        repairSearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane7 = new javax.swing.JScrollPane();
        repairTable = new org.jdesktop.swingx.JXTable();
        repairComboBox = new javax.swing.JComboBox();
        repairItemButton = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        repairResultsPerPageField = new javax.swing.JFormattedTextField();
        repairSearchButton = new javax.swing.JButton();
        repairPageLabel = new javax.swing.JLabel();
        repairPrevButton = new javax.swing.JButton();
        repairNextButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        customerSearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane5 = new javax.swing.JScrollPane();
        customerTable = new org.jdesktop.swingx.JXTable();
        newCustomerButton = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        customersResultsPerPageField = new javax.swing.JFormattedTextField();
        customersSearchButton = new javax.swing.JButton();
        customersPageLabel = new javax.swing.JLabel();
        customersPrevButton = new javax.swing.JButton();
        customersNextButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        staffSearchField = new org.jdesktop.swingx.JXSearchField();
        jScrollPane4 = new javax.swing.JScrollPane();
        staffsTable = new org.jdesktop.swingx.JXTable();
        newStaffButton = new javax.swing.JButton();
        staffPageLabel = new javax.swing.JLabel();
        staffPrevButton = new javax.swing.JButton();
        staffNextButton = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        staffResultsPerPageField = new javax.swing.JFormattedTextField();
        staffSearchButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        usernameMenu = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Kimstore Inventory System");

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        ordersTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Order ID", "Staff", "Customer Type", "Order Date", "Status (Unsortable)"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        ordersTable.setEditable(false);
        ordersTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ordersTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(ordersTable);

        newOrderButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        newOrderButton.setText("New Order");
        newOrderButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newOrderButtonActionPerformed(evt);
            }
        });

        jLabel3.setText("Staff");

        staffFilterComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All" }));
        staffFilterComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                staffFilterComboBoxActionPerformed(evt);
            }
        });

        ordersPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        ordersPrevButton.setText("Previous");

        ordersPageLabel.setText("X/Y");

        ordersNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        ordersNextButton.setText("Next");

        jLabel8.setText("Customer Type");

        ordersCustomerTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Reseller", "Meet Ups", "Shipping", "Consignment", "Marketing" }));

        ordersSearchButton.setText("Search");
        ordersSearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ordersSearchButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Results Per Page");

        resultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        resultsPerPageField.setText("50");
        resultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resultsPerPageFieldActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(newOrderButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(ordersPageLabel)
                        .add(18, 18, 18)
                        .add(ordersPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ordersNextButton)
                        .add(7, 7, 7))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(ordersSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jLabel3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(staffFilterComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 161, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jLabel8)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ordersCustomerTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 123, Short.MAX_VALUE)
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(resultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ordersSearchButton)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(staffFilterComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel8)
                    .add(ordersCustomerTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(ordersSearchButton)
                    .add(jLabel1)
                    .add(resultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(ordersSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newOrderButton)
                    .add(ordersPrevButton)
                    .add(ordersPageLabel)
                    .add(ordersNextButton))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Sales", jPanel1);

        productsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product Name", "Specifications", "Stocks", "SRP", "Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        productsTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                productsTableMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(productsTable);

        newProductButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        newProductButton.setText("New Product");
        newProductButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newProductButtonActionPerformed(evt);
            }
        });

        jLabel4.setText("Product Status");

        inventoryFilterComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Active", "Discontinued" }));
        inventoryFilterComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inventoryFilterComboBoxActionPerformed(evt);
            }
        });

        inventorySearchButton.setText("Search");
        inventorySearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inventorySearchButtonActionPerformed(evt);
            }
        });

        inventoryNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        inventoryNextButton.setText("Next");

        inventoryPreviousButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        inventoryPreviousButton.setText("Previous");

        inventoryPageLabel.setText("X/Y");

        jLabel2.setText("Results Per Page");

        inventoryResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        inventoryResultsPerPageField.setText("50");
        inventoryResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inventoryResultsPerPageFieldActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(newProductButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(inventoryPageLabel)
                        .add(18, 18, 18)
                        .add(inventoryPreviousButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(inventoryNextButton))
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(inventorySearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jLabel4)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(inventoryFilterComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 391, Short.MAX_VALUE)
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(inventoryResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(inventorySearchButton)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel2)
                        .add(inventoryResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(inventorySearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel4)
                        .add(inventoryFilterComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(inventorySearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newProductButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(inventoryNextButton)
                    .add(inventoryPreviousButton)
                    .add(inventoryPageLabel))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Inventory", jPanel4);

        stocksArrivalTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Batch Number", "Date Received", "Staff", "Items (Unsortable)", "Purchase Cost"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        stocksArrivalTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                stocksArrivalTableMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(stocksArrivalTable);

        newStocksButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        newStocksButton.setText("New Stocks");
        newStocksButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newStocksButtonActionPerformed(evt);
            }
        });

        stocksArrivalSearchButton.setText("Search");

        jLabel9.setText("Results Per Page");

        stocksArrivalResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        stocksArrivalResultsPerPageField.setText("50");
        stocksArrivalResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stocksArrivalResultsPerPageFieldActionPerformed(evt);
            }
        });

        stocksArrivalPageLabel.setText("X/Y");

        stocksArrivalPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        stocksArrivalPrevButton.setText("Previous");

        stocksArrivalNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        stocksArrivalNextButton.setText("Next");

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(newStocksButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(stocksArrivalPageLabel)
                        .add(18, 18, 18)
                        .add(stocksArrivalPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(stocksArrivalNextButton))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(stocksArrivalSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 598, Short.MAX_VALUE)
                        .add(jLabel9)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(stocksArrivalResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(stocksArrivalSearchButton)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel9)
                        .add(stocksArrivalResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(stocksArrivalSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(stocksArrivalSearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(stocksArrivalNextButton)
                        .add(stocksArrivalPrevButton)
                        .add(stocksArrivalPageLabel))
                    .add(newStocksButton))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Stocks Arrival", jPanel5);

        itemsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "SKU", "Product Name", "Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        itemsTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                itemsTableMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(itemsTable);

        itemsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Available", "Office Property", "Sold", "Repaired" }));

        jLabel7.setText("Item Status");

        itemsPageLabel.setText("X/Y");

        itemsPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        itemsPrevButton.setText("Previous");

        itemsNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        itemsNextButton.setText("Next");

        jLabel10.setText("Results Per Page");

        itemsResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        itemsResultsPerPageField.setText("50");
        itemsResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemsResultsPerPageFieldActionPerformed(evt);
            }
        });

        itemsSearchButton.setText("Search");

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                    .add(jPanel6Layout.createSequentialGroup()
                        .add(itemsSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(itemsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 151, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 361, Short.MAX_VALUE)
                        .add(jLabel10)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(itemsResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(itemsSearchButton))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(itemsPageLabel)
                        .add(18, 18, 18)
                        .add(itemsPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(itemsNextButton)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(itemsSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(itemsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel7))
                    .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel10)
                            .add(itemsResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(itemsSearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(itemsNextButton)
                    .add(itemsPrevButton)
                    .add(itemsPageLabel))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Items", jPanel6);

        repairTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "SKU", "Product Name", "Receive Date", "Release Date", "Repair Status", "Item Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        repairTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                repairTableMouseClicked(evt);
            }
        });
        jScrollPane7.setViewportView(repairTable);

        repairComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "In Repair", "Repaired" }));

        repairItemButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        repairItemButton.setText("Repair Item");
        repairItemButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                repairItemButtonActionPerformed(evt);
            }
        });

        jLabel5.setText("Repair Status");

        jLabel11.setText("Results Per Page");

        repairResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        repairResultsPerPageField.setText("50");
        repairResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                repairResultsPerPageFieldActionPerformed(evt);
            }
        });

        repairSearchButton.setText("Search");

        repairPageLabel.setText("X/Y");

        repairPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        repairPrevButton.setText("Previous");

        repairNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        repairNextButton.setText("Next");

        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                    .add(jPanel7Layout.createSequentialGroup()
                        .add(repairItemButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(repairPageLabel)
                        .add(18, 18, 18)
                        .add(repairPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(repairNextButton))
                    .add(jPanel7Layout.createSequentialGroup()
                        .add(repairSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(repairComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 136, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 363, Short.MAX_VALUE)
                        .add(jLabel11)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(repairResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(repairSearchButton)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(repairSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(repairComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel5))
                    .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel11)
                            .add(repairResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(repairSearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(repairNextButton)
                        .add(repairPrevButton)
                        .add(repairPageLabel))
                    .add(repairItemButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Repair", jPanel7);

        customerTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "Name", "Last Purchase Date (Unsortable)"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        customerTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                customerTableMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(customerTable);

        newCustomerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        newCustomerButton.setText("New Customer");
        newCustomerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newCustomerButtonActionPerformed(evt);
            }
        });

        jLabel12.setText("Results Per Page");

        customersResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        customersResultsPerPageField.setText("50");
        customersResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customersResultsPerPageFieldActionPerformed(evt);
            }
        });

        customersSearchButton.setText("Search");

        customersPageLabel.setText("X/Y");

        customersPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        customersPrevButton.setText("Previous");

        customersNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        customersNextButton.setText("Next");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(newCustomerButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(customersPageLabel)
                        .add(18, 18, 18)
                        .add(customersPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(customersNextButton))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane5)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(customerSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 598, Short.MAX_VALUE)
                        .add(jLabel12)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(customersResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(customersSearchButton)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(customerSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel12)
                            .add(customersResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(customersSearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(customersNextButton)
                        .add(customersPrevButton)
                        .add(customersPageLabel))
                    .add(newCustomerButton))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Customers", jPanel3);

        staffsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "Name", "Last Delivery (Unsortable)"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        staffsTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                staffsTableMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(staffsTable);

        newStaffButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/math-add-icon.png"))); // NOI18N
        newStaffButton.setText("New Staff");
        newStaffButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newStaffButtonActionPerformed(evt);
            }
        });

        staffPageLabel.setText("X/Y");

        staffPrevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-left-icon.png"))); // NOI18N
        staffPrevButton.setText("Previous");

        staffNextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/kimstore/resources/images/arrow-right-icon.png"))); // NOI18N
        staffNextButton.setText("Next");

        jLabel13.setText("Results Per Page");

        staffResultsPerPageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        staffResultsPerPageField.setText("50");
        staffResultsPerPageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                staffResultsPerPageFieldActionPerformed(evt);
            }
        });

        staffSearchButton.setText("Search");

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane4)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(staffSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 598, Short.MAX_VALUE)
                        .add(jLabel13)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(staffResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(staffSearchButton))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(newStaffButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(staffPageLabel)
                        .add(18, 18, 18)
                        .add(staffPrevButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(staffNextButton)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(staffSearchField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel13)
                            .add(staffResultsPerPageField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(staffSearchButton)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newStaffButton)
                    .add(staffNextButton)
                    .add(staffPrevButton)
                    .add(staffPageLabel))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Staff", jPanel2);

        jMenu1.setText("Reports");

        jMenuItem4.setText("Gross Income");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuItem5.setText("Net Income");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem5);

        jMenuItem6.setText("Repair");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem6);

        jMenuItem7.setText("Performance");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem7);

        jMenuItem8.setText("In and Out");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem8);

        jMenuItem9.setText("Sales");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem9);

        jMenuBar1.add(jMenu1);

        usernameMenu.setText("<username>");

        jMenuItem1.setText("Log Out");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        usernameMenu.add(jMenuItem1);

        jMenuItem2.setText("Change Password");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        usernameMenu.add(jMenuItem2);

        jMenuBar1.add(usernameMenu);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTabbedPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void newOrderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newOrderButtonActionPerformed
        if (DaoFactory.getInstance().getStaffDao().exists()) {
            ordersTabController.createNewOrderWindow();
        } else {
            JOptionPane.showMessageDialog(this, "Add a staff entry first", "Missing Staff Entries", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_newOrderButtonActionPerformed

    private void newProductButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newProductButtonActionPerformed
        inventoryTabController.createNewProductController();
    }//GEN-LAST:event_newProductButtonActionPerformed

    private void newStocksButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newStocksButtonActionPerformed
        if (DaoFactory.getInstance().getStaffDao().exists()) {
            stocksArrivalTabController.createNewStocksController();
        } else {
            JOptionPane.showMessageDialog(this, "Add a staff entry first", "Missing Staff Entries", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_newStocksButtonActionPerformed

    private void ordersTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ordersTableMouseClicked
        if (evt.getClickCount() == 2) {
            int row = ordersTable.getSelectedRow();
            Integer orderId = Integer.parseInt(ordersTable.getValueAt(row, 0) + "");

            ordersTabController.createViewUpdateOrderWindow(orderId);
        }
    }//GEN-LAST:event_ordersTableMouseClicked

    private void productsTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_productsTableMouseClicked
        if (evt.getClickCount() == 2) {
            String productName = productsTable.getValueAt(productsTable.getSelectedRow(), 0) + "";
            inventoryTabController.createViewProductController(productName);
        }
    }//GEN-LAST:event_productsTableMouseClicked

    private void stocksArrivalTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_stocksArrivalTableMouseClicked
        if (evt.getClickCount() == 2) {
            String batchNumber = stocksArrivalTable.getValueAt(stocksArrivalTable.getSelectedRow(), 0) + "";
            stocksArrivalTabController.createViewBatchController(batchNumber);
        }
    }//GEN-LAST:event_stocksArrivalTableMouseClicked

    private void newStaffButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newStaffButtonActionPerformed
        staffTabController.createNewStaffController();
    }//GEN-LAST:event_newStaffButtonActionPerformed

    private void newCustomerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newCustomerButtonActionPerformed
        customerTabController.createNewCustomerController();
    }//GEN-LAST:event_newCustomerButtonActionPerformed

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
//        System.out.println(jTabbedPane1.getSelectedIndex());
        switch (jTabbedPane1.getSelectedIndex()) {
            case 0:
                ordersTabController.refreshTable();
                ordersTabController.refreshComboBox();
                break;
            case 1:
                inventoryTabController.refreshTable();
                break;
            case 2:
                stocksArrivalTabController.refreshTable();
                break;
            case 3:
                itemsTabController.refreshTable();
                break;
            case 4:
                repairTabController.refreshTable();
                break;
            case 5:
                customerTabController.refreshTable();
                break;
            case 6:
                staffTabController.refreshTable();
                break;
        }
    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void staffFilterComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_staffFilterComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_staffFilterComboBoxActionPerformed

    private void itemsTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemsTableMouseClicked
        if (evt.getClickCount() == 2) {
            String SKU = itemsTable.getValueAt(itemsTable.getSelectedRow(), 0) + "";
            itemsTabController.createViewItemWindow(SKU);
        }
    }//GEN-LAST:event_itemsTableMouseClicked

    private void repairItemButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_repairItemButtonActionPerformed
        if (DaoFactory.getInstance().getStaffDao().exists()) {
            repairTabController.createAddItemToRepairController();
        } else {
            JOptionPane.showMessageDialog(this, "Add a staff entry first", "Missing Staff Entries", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_repairItemButtonActionPerformed

    private void customerTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customerTableMouseClicked
        if (evt.getClickCount() == 2) {
            String customerName = customerTable.getValueAt(customerTable.getSelectedRow(), 1) + "";
            customerTabController.createViewCustomerController(customerName);
        }
    }//GEN-LAST:event_customerTableMouseClicked

    private void repairTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_repairTableMouseClicked
        if (evt.getClickCount() == 2) {
            String SKU = repairTable.getValueAt(repairTable.getSelectedRow(), 0) + "";
            repairTabController.createViewItemForRepairController(SKU);
        }
    }//GEN-LAST:event_repairTableMouseClicked

    private void staffsTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_staffsTableMouseClicked
        if (evt.getClickCount() == 2) {
            String staffId = staffsTable.getValueAt(staffsTable.getSelectedRow(), 0) + "";
            staffTabController.createViewStaffController(staffId);
        }
    }//GEN-LAST:event_staffsTableMouseClicked

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        reportController.displayWindow(1);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
        reportController.displayWindow(2);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        reportController.displayWindow(0);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        reportController.displayWindow(3);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        reportController.displayWindow(4);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        reportController.displayWindow(5);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void ordersSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ordersSearchButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ordersSearchButtonActionPerformed

    private void resultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_resultsPerPageFieldActionPerformed

    private void inventoryFilterComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inventoryFilterComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_inventoryFilterComboBoxActionPerformed

    private void inventoryResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inventoryResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_inventoryResultsPerPageFieldActionPerformed

    private void stocksArrivalResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stocksArrivalResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_stocksArrivalResultsPerPageFieldActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        this.dispose();
        new LogIn();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void itemsResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemsResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_itemsResultsPerPageFieldActionPerformed

    private void repairResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_repairResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_repairResultsPerPageFieldActionPerformed

    private void customersResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customersResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_customersResultsPerPageFieldActionPerformed

    private void staffResultsPerPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_staffResultsPerPageFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_staffResultsPerPageFieldActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        new ManageCredentialsWindow();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void inventorySearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inventorySearchButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_inventorySearchButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXSearchField customerSearchField;
    private org.jdesktop.swingx.JXTable customerTable;
    private javax.swing.JButton customersNextButton;
    private javax.swing.JLabel customersPageLabel;
    private javax.swing.JButton customersPrevButton;
    private javax.swing.JFormattedTextField customersResultsPerPageField;
    private javax.swing.JButton customersSearchButton;
    private javax.swing.JComboBox inventoryFilterComboBox;
    private javax.swing.JButton inventoryNextButton;
    private javax.swing.JLabel inventoryPageLabel;
    private javax.swing.JButton inventoryPreviousButton;
    private javax.swing.JFormattedTextField inventoryResultsPerPageField;
    private javax.swing.JButton inventorySearchButton;
    private org.jdesktop.swingx.JXSearchField inventorySearchField;
    private javax.swing.JComboBox itemsComboBox;
    private javax.swing.JButton itemsNextButton;
    private javax.swing.JLabel itemsPageLabel;
    private javax.swing.JButton itemsPrevButton;
    private javax.swing.JFormattedTextField itemsResultsPerPageField;
    private javax.swing.JButton itemsSearchButton;
    private org.jdesktop.swingx.JXSearchField itemsSearchField;
    private org.jdesktop.swingx.JXTable itemsTable;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton newCustomerButton;
    private javax.swing.JButton newOrderButton;
    private org.jdesktop.swingx.JXButton newProductButton;
    private javax.swing.JButton newStaffButton;
    private javax.swing.JButton newStocksButton;
    private javax.swing.JComboBox ordersCustomerTypeComboBox;
    private javax.swing.JButton ordersNextButton;
    private javax.swing.JLabel ordersPageLabel;
    private javax.swing.JButton ordersPrevButton;
    private javax.swing.JButton ordersSearchButton;
    private org.jdesktop.swingx.JXSearchField ordersSearchField;
    private org.jdesktop.swingx.JXTable ordersTable;
    private org.jdesktop.swingx.JXTable productsTable;
    private javax.swing.JComboBox repairComboBox;
    private javax.swing.JButton repairItemButton;
    private javax.swing.JButton repairNextButton;
    private javax.swing.JLabel repairPageLabel;
    private javax.swing.JButton repairPrevButton;
    private javax.swing.JFormattedTextField repairResultsPerPageField;
    private javax.swing.JButton repairSearchButton;
    private org.jdesktop.swingx.JXSearchField repairSearchField;
    private org.jdesktop.swingx.JXTable repairTable;
    private javax.swing.JFormattedTextField resultsPerPageField;
    private javax.swing.JComboBox staffFilterComboBox;
    private javax.swing.JButton staffNextButton;
    private javax.swing.JLabel staffPageLabel;
    private javax.swing.JButton staffPrevButton;
    private javax.swing.JFormattedTextField staffResultsPerPageField;
    private javax.swing.JButton staffSearchButton;
    private org.jdesktop.swingx.JXSearchField staffSearchField;
    private org.jdesktop.swingx.JXTable staffsTable;
    private javax.swing.JButton stocksArrivalNextButton;
    private javax.swing.JLabel stocksArrivalPageLabel;
    private javax.swing.JButton stocksArrivalPrevButton;
    private javax.swing.JFormattedTextField stocksArrivalResultsPerPageField;
    private javax.swing.JButton stocksArrivalSearchButton;
    private org.jdesktop.swingx.JXSearchField stocksArrivalSearchField;
    private org.jdesktop.swingx.JXTable stocksArrivalTable;
    private javax.swing.JMenu usernameMenu;
    // End of variables declaration//GEN-END:variables

    public StocksArrivalTabController getStocksArrivalTabController() {
        return stocksArrivalTabController;
    }

    public void setStocksArrivalTabController(StocksArrivalTabController stocksArrivalTabController) {
        this.stocksArrivalTabController = stocksArrivalTabController;
    }

    public OrdersTabController getOrdersTabController() {
        return ordersTabController;
    }

    public void setOrdersTabController(OrdersTabController ordersTabController) {
        this.ordersTabController = ordersTabController;
    }

    public InventoryTabController getInventoryTabController() {
        return inventoryTabController;
    }

    public void setInventoryTabController(InventoryTabController inventoryTabController) {
        this.inventoryTabController = inventoryTabController;
    }

    public ItemsTabController getItemsTabController() {
        return itemsTabController;
    }

    public RepairTabController getRepairTabController() {
        return repairTabController;
    }

    public CustomerTabController getCustomerTabController() {
        return customerTabController;
    }

    public StaffTabController getStaffTabController() {
        return staffTabController;
    }
}
